<?php
/**
 * Created by Benjiemin
 * Date: 2020/2/27
 * Time: 10:19
 */
require ('./vendor/autoload.php');
use QL\QueryList;
use QL\Ext\Chrome;

$ql = QueryList::getInstance();
// 注册插件，默认注册的方法名为: chrome
$ql->use(Chrome::class);
$text = $ql->chrome(function ($page,$browser) {
    $page->goto('http://bbs.xmfish.com/login.php');
    // 这里故意设置一个很长的延长时间，让你可以看到chrome浏览器的启动
    $username = 'tulouguli';
    $password = 'jian168@';
    sleep(3);
    $page->click('div .login-switch-static a');

    $page->type("input[name='username']",$username);
    $page->type("input[name='password']",$password);
    sleep(1);
    $page->click("input[type='submit']");
    //执行登录
    sleep(3);
    //回帖
    $page->goto('http://bbs.xmfish.com/read-htm-tid-16685729.html');
    sleep(3);
    $page->waitForSelector("#textarea");
    $page->type("#textarea",'备胎了，节哀', 100);
    $page->click("button[name='Submit']");
    //textarea
    sleep(3);
    $html = $page->content();
    sleep(10);
    $browser->close();
    // 返回值一定要是页面的HTML内容
    return $html;
},[
    'headless' => false, // 启动可视化Chrome浏览器,方便调试
    'devtools' => false, // 打开浏览器的开发者工具
])->find('title')->text();

echo $text;